<!DOCTYPE html>

<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>数据</title>
    <!-- Bootstrap JQ核心CSS 、JS-->
    <script src="/static/jquery/3.5.1/jquery.min.js" type="text/javascript"></script>
    <link href="/static/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="/static/bootstrap/3.3.7/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/static/linling-core-tools/js/linling-core-tools.js" type="text/javascript"></script>
    <!-- 适用于Surface /台式机Windows 8错误的IE10视口黑客 -->
    <script src="/static/linling-core-tools/js/ie10-viewport-bug-workaround.js" type="text/javascript"></script>
    <link href="/static/linling-core-tools/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
    <script type="text/javascript">
        let nowPage = 1;
        let sumPage = 1;
        $(function () {
            nowPage = parseInt($("#pageNum").html());
            sumPage = parseInt($("#pages").html());
        })

        function search() {
            let key = $("#nameKey").val();
            location.href = "/content?key=" + key;
        }

        function renew() {
            location.href = "/content";
        }

        function page(page) {
            if (page > sumPage) {
                alert("已经是最后一页！");
                return;
            }
            if (page < 1) {
                alert("已经是第一页！")
                return;
            }

            let key = $("#nameKey").val();
            location.href = "/content?key=" + key + "&page=" + page;
        }

        function add() {
            location.href = "/content/add";
        }

    </script>
</head>
<body>
<h1 class="page-header">数据统计</h1>
<span>搜索：</span>
<label for="nameKey" class="form-inline">
    <input type="text" id="nameKey" class="form-control" th:value="${key}">&nbsp;&nbsp;
</label>
<button id="search" class="btn btn-primary" onclick="search()">
    <span class="glyphicon glyphicon-search"></span> 搜索
</button>&nbsp;
<button id="reset" class="btn btn-danger" onclick="renew()">
    <span class="glyphicon glyphicon-repeat"></span> 恢复
</button>

<button class="btn btn-success" onclick="add()">
    <span class="glyphicon glyphicon-plus"></span> 添加数据
</button>&nbsp;

共找到<span id="sumRows" style="color: crimson" th:text="${count}"></span>条数据&nbsp;
本页共<span style="color: crimson" th:text="${content.size()}"></span>条
<div class="table-responsive">
    <table id="listCustomer" class="table">
        <thead>
        <tr>
            <th>类型</th>
            <th>平台</th>
            <th>内容</th>
            <th>时间</th>
            <th>媒体数据</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="searchVar">
        <!-- 预留数据 -->
        <tr th:each="row:${content}">
            <td th:text="${row.getType()}"></td>
            <td th:text="${row.getPlatform()}"></td>
            <td th:text="${row.getValue()}" style="width:50%"></td>
            <td th:text="${row.getCreateTime()}"></td>
            <td>
                <p>阅读:<span style="color: #28a4c9" th:text="${row.getView()}"></span></p>
                <p>评论:<span style="color: #c928b4" th:text="${row.getComment()}"></span></p>
                <p>转发:<span style="color: #b1c928" th:text="${row.getTransmit()}"></span></p>
                <p>投币:<span style="color: #dd5ff5" th:text="${row.getCoin()}"></span></p>
            </td>
            <td>
                <p><a href="#" th:href="${row.getUrl()}">详情</a></p>
                <p><a href="#" th:href="'/content/modify?id='+${row.getId()}">编辑</a></p>
                <p><a href="#" th:href="'/content/remove?id='+${row.getId()}">删除</a></p>
            </td>

        </tr>

        </tbody>
        <tfoot>
        <!-- 尾部数据 -->
        <tr></tr>
        </tfoot>
    </table>
</div>

<div class="icon-align-center">
    <a href="#" id="start" onclick="page(1)">首页</a>
    <button id="upon" onclick="page(nowPage-1)">上一页</button>&nbsp;
    第<span id="pageNum" style="color: #142fdc" th:text="${page}"></span>页&nbsp;
    共<span id="pages" th:text="${pageCount}"></span>页&nbsp;
    <button id="next" onclick="page(nowPage+1)">下一页</button>&nbsp;
    <a href="#" id="last" onclick="page(sumPage)">末页</a>
</div>
</body>
</html>